require('../css/login.less')
require('../fonts/iconfont.css')


let login = document.querySelector('.login')
let acc = document.querySelector('.acc')
let pwd = document.querySelector('.pwd')
let toast = document.querySelector('.toast')
console.log(toast);

//点击登录按钮
login.addEventListener('click', function () {
    let data = {
        account: acc.value,
        password: pwd.value
    }
    //判定输入框不能为空
    if (acc.value == '' || pwd.value == '') {
        return
    }
    //请求登录 Ajax
    $http.post('/users/login', data, function (res) {
        //判断状态
        if (res.status == 555) {
            utils.show(1,'账号或密码错误')
            return
        }
        //本地存储存入账号消息
        localStorage.setItem('user', JSON.stringify(res.data.user))
        //页面跳转
        location.href = '../page/home.html';

    })

})
